import axios, { AxiosInstance, InternalAxiosRequestConfig, AxiosResponse } from 'axios'

// 创建实例
const http: AxiosInstance = axios.create({
    baseURL: '/api',
    timeout: 1000,
    headers: {}
})

// 请求拦截器
http.interceptors.request.use((config: InternalAxiosRequestConfig) => {
        return config;
    },(error: any) => {
        return Promise.reject(error)
    }
)

// 响应拦截器
http.interceptors.response.use((response: AxiosResponse) => {
        return response
    },(error: any) => {
        return Promise.reject(error)
    }
)

export default http